<?php
//include("confing.php");
define("TOKEN" ,"weixin");

$wechatObj  =   new wechat();
$wechatObj ->responseMsg();

class wechat{
	      public  function valid()
		  {
		     if($this->checkSignature()){
				  echo $echoStr;
				  exit;
				 }
		  } 
		  
		  public function responseMsg(){
			   $postStr =$GLOBALS["HTTP_RAW_POST_DATA"];
			   
			   if(!empty($postStr)){
			 	$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
                $keyword = trim($postObj->Content);
				if(!empty($keyword)){
					  $contentStr ="欢迎关注！";
					  $resultStr    =_response_text($postObj,$contentStr);
					  echo $contentStr;
					}else{
						 	echo "Input something...";
						}
				   }else{
					        	echo "";
                            	exit;
					   }
			  }
	
	
	private function checkSignature()
	{
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];	
        		
		$token = TOKEN;
		$tmpArr = array($token, $timestamp, $nonce);
		sort($tmpArr);
		$tmpStr = implode( $tmpArr );
		$tmpStr = sha1( $tmpStr );
		
		if( $tmpStr == $signature ){
			return true;
		}else{
			return false;
		}
	}
	
	}
?>